<template>
<el-dialog v-bind="dialogAttrs">
    <slot></slot>
    <template v-if="showFooter" #footer>
        <span>
            <template v-if="!$slots.footer">
                <el-button @click="handleCancel">取消</el-button>
                <el-button type="primary" :loading="loading" @click="handleConfirm">确定</el-button>
            </template>
            <slot v-else ></slot>
        </span>
    </template>
</el-dialog>
</template>

<script setup>
import { useAttrs, computed } from "vue";
import { ElDialog, ElButton } from "element-plus";
defineProps({
    showFooter: {
        type: Boolean,
        default: true,
    },
    loading: {
        type: Boolean,
        default: false,	
    }
});
const emit = defineEmits(["dialogCancel", "dialogConfirm"]);
const attrs = useAttrs();
const dialogAttrs = computed(() => ({
    ...attrs,
}));
function handleCancel() {
    emit("dialogCancel");
}
function handleConfirm() {
    emit("dialogConfirm");
}
</script>
